package com.ruoyi.business.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.business.domain.FreightVehicleTrail;
import com.ruoyi.business.domain.vo.FreightVehicleTrailVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;

/**
 * 运单轨迹Mapper接口
 *
 * @author ruoyi
 * @date 2024-04-20
 */
public interface FreightVehicleTrailMapper extends BaseMapperPlus<FreightVehicleTrailMapper, FreightVehicleTrail, FreightVehicleTrailVo> {


    /**
     * 根据主表id查询最新的轨迹
     *
     * @param masterId
     * @return
     */
    default FreightVehicleTrailVo selectLatestTrailByMasterId(Long masterId) {
        return selectVoOne(new LambdaQueryWrapper<FreightVehicleTrail>()
            .eq(FreightVehicleTrail::getFreightId, masterId)
            .orderByDesc(FreightVehicleTrail::getRecordTime)
            .last("limit 1")
        );
    }
}
